#!/bin/sh
module="sculluid"
device=$module
param1="scull_major"

modulepath=/lib/modules/3.5.0-FriendlyARM-g042a5377-dirty

cp /home/plg/$module.ko $modulepath

rm $modulepath/modules.dep.bb

rm -f /dev/${device}[0-3]

oldmodule=$(awk "\$2==\"$module\" {print \$2}" /proc/devices)
echo oldmoudle = $oldmodule

if [ $oldmodule == $module ]; then
    echo oldmoudle = $oldmodule
    modprobe -r $module
fi

if [ $1 ]; then
    echo modprobe $module $param1=$1
    modprobe $module $param1=$1
else
    echo modprobe $module
    modprobe $module
fi

major=$(awk "\$2==\"$module\" {print \$1}" /proc/devices)
echo major = $major
mknod /dev/${device}0 c $major 0 
mknod /dev/${device}1 c $major 1
mknod /dev/${device}2 c $major 2
mknod /dev/${device}3 c $major 3

ls -l /dev/$device*
